package com.qf.dao.impl;

import com.qf.dao.OrderDetailDao;
import com.qf.util.JDBCUtil;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;

public class OrderDetailDaoImpl implements OrderDetailDao {
    QueryRunner qr=new QueryRunner();
    @Override
    public int insertOrderDetail(Integer pid, Integer cnum, Integer oid) {
        Connection con=null;
        int a=0;
        try{
            con= JDBCUtil.getCon();
            String sql="insert into orderitem (oid,pid,num) values(?,?,?)";
            a = qr.update(con, sql,oid,pid,cnum);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            JDBCUtil.colseCon(con);
        }

        return a;


    }
}
